<?php
include_once('class/autoload.php'); // pour inclure nos classes
$site = new page_securisee('accueil');
if (utilCoTypeC($_SESSION['identifiant']) == 1){
if(isset($_POST['idCab']))
{
	$idCab=$_POST['idCab'];
}
else{
	$idCab=$_POST['idCabEdit'];
	//Si on a cliqué sur supprimer licence
	if(isset($_POST['DelCab'])){
		supp_Lic_Cab($_POST['idCabEdit'], $_POST['idLic']);
	}
	//Si on a cliqué sur ajouter licence
	else if(isset($_POST['AddLicCab'])){
		$site->corps.=ajout_Lic_Cab($_POST['idCabEdit'], $_POST['typeLic']);
	}
	//Si on a cliqué sur modifier le compte
	else if(isset($_POST['ModifCab'])){ 
		$site->corps.=modif_Cab($_POST['idCabEdit'] ,$_POST['nomCabEdit'], $_POST['telCabEdit'], $_POST['NVoieEdit'], $_POST['LvoieEdit'], $_POST['CPEdit'], $_POST['VilleEdit'],$_POST['PaysEdit']);
		//Pour mettre à jour le quota de SMS, décommenter
		//setQuota($_POST['idPratEdit'],$_POST['quotaSmsPratEdit']);
	}
	//Si on a cliqué sur supprimer le compte
	else if(isset($_POST['DelAll'])){
		supp_Prat($_POST['idPratEdit']); 
	}
	//Si on a cliqué sur modifier licence
	else if(isset($_POST['ModifLicCab'])){
		modif_Lic_Cab($_POST['idCabEdit'], $_POST['idLic'], $_POST['dateLicEdit']);
	}
	else if(isset($_POST['AddtoCab'])&&!empty($_POST['AddtoCab'])){
		$site->corps = AddToCab($_POST['AddtoCab'],$idCab);
	}
}
$site->corps .= 
'<form method="post" action="editCabinet.php"/>
    <h2 class="form-signin-heading">Edition du Cabinet</h2>
		<table class="table table-striped">
  			<thead>
  				<tr>
  					<th>#</th>
  					<th>Nom</th>
  					<th>Téléphone</th>
					<th>Adresse</th>
  				</tr>
  			</thead>
  			<tbody>
  				<tr>
  					'.edit_cabinet_info($idCab).'
  				</tr>
  			</tbody>
  		</table>
  		<br />
  		
  		<br />
		<div align="center">
			<button type="submit" name="ModifCab" class="btn btn-primary">Modifier le compte client</button>
			<button type="submit" name="DelCab" class="btn btn-danger">Supprimer le compte client</button>
		</div>	
		<br /><hr>
  		<h2>Praticiens membre de ce cabinet</h2>
  		<table class="table table-striped">
	        <thead>
	        	<tr>
	        		<th>#</th>
	        		<th>Nom</th>
	        		<th>Prenom</th>
	        	</tr>
	        </thead>	
	        <tbody>
	        	'.Prat_cabinet($idCab).'
	        </tbody>
  		</table>
	    <div class="form-inline ui-widget">
	    	<input type="text" class="form-control" id="AutoComplete" placeholder="Saisir le nom d\'un praticien"/>
	        <input type="submit" class="btn btn-primary"/>
	        <input type="hidden" name="AddtoCab" id="idPrat"/>
	    </div>	
  		<br /><br />
	    <table class="table table-striped">
	        <thead>
	        	<tr>
	        		<th>#</th>
	        		<th>Licences</th>
	        		<th>Date d\'expiration</th>
	        		<th>&nbsp;</th>
					<th>&nbsp;</th>
	        	</tr>
	        </thead>	
	        <tbody>
	        	'.edit_cabinet_licences($idCab).'
	        </tbody>
  		</table>
		<br /><br />
  		<table class="table table-striped">
  			<tbody>
  				<tr>
  					<td>Ajouter une licence :</td>
					<td>
  						<select name="typeLic" class="form-control">
	  						'.type_lic().'
	  					</select>
	  				</td>
						<td><button type="submit" name="AddLicCab" class="btn btn-success">Ajouter</button></td>
  				</tr>
  			</tbody>
  		</table>
</form>';
}
else{
	$site->corps = 'Vous ne pouvez pas acc&eacuteder &agrave cette page.';
}
$site->affiche();
?>